blob: aabb2c38a746bb219b0a4696d4404d870ad770e5 [file] [log] [blame]
Junio C Hamanof2b74942012-11-20 21:06:261<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
2 "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
3<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
4<head>
Junio C Hamano9d971152012-12-19 00:43:115<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8" />
6<meta name="generator" content="AsciiDoc 8.6.8" />
Junio C Hamanof2b74942012-11-20 21:06:267<title>Packfile transfer protocols</title>
8<style type="text/css">
Junio C Hamano9d971152012-12-19 00:43:119/* Shared CSS for AsciiDoc xhtml11 and html5 backends */
10
11/* Default font. */
12body {
13 font-family: Georgia,serif;
14}
15
16/* Title font. */
17h1, h2, h3, h4, h5, h6,
18div.title, caption.title,
19thead, p.table.header,
20#toctitle,
21#author, #revnumber, #revdate, #revremark,
22#footer {
23 font-family: Arial,Helvetica,sans-serif;
Junio C Hamanof2b74942012-11-20 21:06:2624}
25
26body {
27 margin: 1em 5% 1em 5%;
28}
29
30a {
31 color: blue;
32 text-decoration: underline;
33}
34a:visited {
35 color: fuchsia;
36}
37
38em {
39 font-style: italic;
40 color: navy;
41}
42
43strong {
44 font-weight: bold;
45 color: #083194;
46}
47
Junio C Hamanof2b74942012-11-20 21:06:2648h1, h2, h3, h4, h5, h6 {
49 color: #527bbd;
Junio C Hamanof2b74942012-11-20 21:06:2650 margin-top: 1.2em;
51 margin-bottom: 0.5em;
52 line-height: 1.3;
53}
54
55h1, h2, h3 {
56 border-bottom: 2px solid silver;
57}
58h2 {
59 padding-top: 0.5em;
60}
61h3 {
62 float: left;
63}
64h3 + * {
65 clear: left;
66}
Junio C Hamano9d971152012-12-19 00:43:1167h5 {
68 font-size: 1.0em;
69}
Junio C Hamanof2b74942012-11-20 21:06:2670
71div.sectionbody {
Junio C Hamanof2b74942012-11-20 21:06:2672 margin-left: 0;
73}
74
75hr {
76 border: 1px solid silver;
77}
78
79p {
80 margin-top: 0.5em;
81 margin-bottom: 0.5em;
82}
83
84ul, ol, li > p {
85 margin-top: 0;
86}
Junio C Hamano9d971152012-12-19 00:43:1187ul > li { color: #aaa; }
88ul > li > * { color: black; }
Junio C Hamanof2b74942012-11-20 21:06:2689
Junio C Hamano9d971152012-12-19 00:43:1190.monospaced, code, pre {
91 font-family: "Courier New", Courier, monospace;
92 font-size: inherit;
93 color: navy;
Junio C Hamanof2b74942012-11-20 21:06:2694 padding: 0;
95 margin: 0;
96}
97
Junio C Hamano9d971152012-12-19 00:43:1198
99#author {
Junio C Hamanof2b74942012-11-20 21:06:26100 color: #527bbd;
Junio C Hamanof2b74942012-11-20 21:06:26101 font-weight: bold;
102 font-size: 1.1em;
103}
Junio C Hamano9d971152012-12-19 00:43:11104#email {
Junio C Hamanof2b74942012-11-20 21:06:26105}
Junio C Hamano9d971152012-12-19 00:43:11106#revnumber, #revdate, #revremark {
Junio C Hamanof2b74942012-11-20 21:06:26107}
108
Junio C Hamano9d971152012-12-19 00:43:11109#footer {
Junio C Hamanof2b74942012-11-20 21:06:26110 font-size: small;
111 border-top: 2px solid silver;
112 padding-top: 0.5em;
113 margin-top: 4.0em;
114}
Junio C Hamano9d971152012-12-19 00:43:11115#footer-text {
Junio C Hamanof2b74942012-11-20 21:06:26116 float: left;
117 padding-bottom: 0.5em;
118}
Junio C Hamano9d971152012-12-19 00:43:11119#footer-badges {
Junio C Hamanof2b74942012-11-20 21:06:26120 float: right;
121 padding-bottom: 0.5em;
122}
123
Junio C Hamano9d971152012-12-19 00:43:11124#preamble {
Junio C Hamanof2b74942012-11-20 21:06:26125 margin-top: 1.5em;
126 margin-bottom: 1.5em;
127}
Junio C Hamano9d971152012-12-19 00:43:11128div.imageblock, div.exampleblock, div.verseblock,
Junio C Hamanof2b74942012-11-20 21:06:26129div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock,
130div.admonitionblock {
131 margin-top: 1.0em;
132 margin-bottom: 1.5em;
133}
134div.admonitionblock {
135 margin-top: 2.0em;
136 margin-bottom: 2.0em;
137 margin-right: 10%;
138 color: #606060;
139}
140
141div.content { /* Block element content. */
142 padding: 0;
143}
144
145/* Block element titles. */
146div.title, caption.title {
147 color: #527bbd;
Junio C Hamanof2b74942012-11-20 21:06:26148 font-weight: bold;
149 text-align: left;
150 margin-top: 1.0em;
151 margin-bottom: 0.5em;
152}
153div.title + * {
154 margin-top: 0;
155}
156
157td div.title:first-child {
158 margin-top: 0.0em;
159}
160div.content div.title:first-child {
161 margin-top: 0.0em;
162}
163div.content + div.title {
164 margin-top: 0.0em;
165}
166
167div.sidebarblock > div.content {
168 background: #ffffee;
Junio C Hamano9d971152012-12-19 00:43:11169 border: 1px solid #dddddd;
170 border-left: 4px solid #f0f0f0;
Junio C Hamanof2b74942012-11-20 21:06:26171 padding: 0.5em;
172}
173
174div.listingblock > div.content {
Junio C Hamano9d971152012-12-19 00:43:11175 border: 1px solid #dddddd;
176 border-left: 5px solid #f0f0f0;
177 background: #f8f8f8;
Junio C Hamanof2b74942012-11-20 21:06:26178 padding: 0.5em;
179}
180
181div.quoteblock, div.verseblock {
182 padding-left: 1.0em;
183 margin-left: 1.0em;
184 margin-right: 10%;
Junio C Hamano9d971152012-12-19 00:43:11185 border-left: 5px solid #f0f0f0;
186 color: #888;
Junio C Hamanof2b74942012-11-20 21:06:26187}
188
189div.quoteblock > div.attribution {
190 padding-top: 0.5em;
191 text-align: right;
192}
193
Junio C Hamano9d971152012-12-19 00:43:11194div.verseblock > pre.content {
195 font-family: inherit;
196 font-size: inherit;
Junio C Hamanof2b74942012-11-20 21:06:26197}
198div.verseblock > div.attribution {
199 padding-top: 0.75em;
200 text-align: left;
201}
202/* DEPRECATED: Pre version 8.2.7 verse style literal block. */
203div.verseblock + div.attribution {
204 text-align: left;
205}
206
207div.admonitionblock .icon {
208 vertical-align: top;
209 font-size: 1.1em;
210 font-weight: bold;
211 text-decoration: underline;
212 color: #527bbd;
213 padding-right: 0.5em;
214}
215div.admonitionblock td.content {
216 padding-left: 0.5em;
217 border-left: 3px solid #dddddd;
218}
219
220div.exampleblock > div.content {
221 border-left: 3px solid #dddddd;
222 padding-left: 0.5em;
223}
224
225div.imageblock div.content { padding-left: 0; }
226span.image img { border-style: none; }
227a.image:visited { color: white; }
228
229dl {
230 margin-top: 0.8em;
231 margin-bottom: 0.8em;
232}
233dt {
234 margin-top: 0.5em;
235 margin-bottom: 0;
236 font-style: normal;
237 color: navy;
238}
239dd > *:first-child {
240 margin-top: 0.1em;
241}
242
243ul, ol {
244 list-style-position: outside;
245}
246ol.arabic {
247 list-style-type: decimal;
248}
249ol.loweralpha {
250 list-style-type: lower-alpha;
251}
252ol.upperalpha {
253 list-style-type: upper-alpha;
254}
255ol.lowerroman {
256 list-style-type: lower-roman;
257}
258ol.upperroman {
259 list-style-type: upper-roman;
260}
261
262div.compact ul, div.compact ol,
263div.compact p, div.compact p,
264div.compact div, div.compact div {
265 margin-top: 0.1em;
266 margin-bottom: 0.1em;
267}
268
Junio C Hamanof2b74942012-11-20 21:06:26269tfoot {
270 font-weight: bold;
271}
272td > div.verse {
273 white-space: pre;
274}
Junio C Hamanof2b74942012-11-20 21:06:26275
276div.hdlist {
277 margin-top: 0.8em;
278 margin-bottom: 0.8em;
279}
280div.hdlist tr {
281 padding-bottom: 15px;
282}
283dt.hdlist1.strong, td.hdlist1.strong {
284 font-weight: bold;
285}
286td.hdlist1 {
287 vertical-align: top;
288 font-style: normal;
289 padding-right: 0.8em;
290 color: navy;
291}
292td.hdlist2 {
293 vertical-align: top;
294}
295div.hdlist.compact tr {
296 margin: 0;
297 padding-bottom: 0;
298}
299
300.comment {
301 background: yellow;
302}
303
304.footnote, .footnoteref {
305 font-size: 0.8em;
306}
307
308span.footnote, span.footnoteref {
309 vertical-align: super;
310}
311
312#footnotes {
313 margin: 20px 0 20px 0;
314 padding: 7px 0 0 0;
315}
316
317#footnotes div.footnote {
318 margin: 0 0 5px 0;
319}
320
321#footnotes hr {
322 border: none;
323 border-top: 1px solid silver;
324 height: 1px;
325 text-align: left;
326 margin-left: 0;
327 width: 20%;
328 min-width: 100px;
329}
330
Junio C Hamano9d971152012-12-19 00:43:11331div.colist td {
332 padding-right: 0.5em;
333 padding-bottom: 0.3em;
334 vertical-align: top;
335}
336div.colist td img {
337 margin-top: 0.3em;
Junio C Hamanof2b74942012-11-20 21:06:26338}
339
Junio C Hamano9d971152012-12-19 00:43:11340@media print {
341 #footer-badges { display: none; }
342}
343
344#toc {
Junio C Hamanof2b74942012-11-20 21:06:26345 margin-bottom: 2.5em;
346}
347
Junio C Hamano9d971152012-12-19 00:43:11348#toctitle {
Junio C Hamanof2b74942012-11-20 21:06:26349 color: #527bbd;
Junio C Hamanof2b74942012-11-20 21:06:26350 font-size: 1.1em;
351 font-weight: bold;
352 margin-top: 1.0em;
353 margin-bottom: 0.1em;
354}
355
Junio C Hamano9d971152012-12-19 00:43:11356div.toclevel0, div.toclevel1, div.toclevel2, div.toclevel3, div.toclevel4 {
Junio C Hamanof2b74942012-11-20 21:06:26357 margin-top: 0;
358 margin-bottom: 0;
359}
360div.toclevel2 {
361 margin-left: 2em;
362 font-size: 0.9em;
363}
364div.toclevel3 {
365 margin-left: 4em;
366 font-size: 0.9em;
367}
368div.toclevel4 {
369 margin-left: 6em;
370 font-size: 0.9em;
371}
Junio C Hamanof2b74942012-11-20 21:06:26372
Junio C Hamano9d971152012-12-19 00:43:11373span.aqua { color: aqua; }
374span.black { color: black; }
375span.blue { color: blue; }
376span.fuchsia { color: fuchsia; }
377span.gray { color: gray; }
378span.green { color: green; }
379span.lime { color: lime; }
380span.maroon { color: maroon; }
381span.navy { color: navy; }
382span.olive { color: olive; }
383span.purple { color: purple; }
384span.red { color: red; }
385span.silver { color: silver; }
386span.teal { color: teal; }
387span.white { color: white; }
388span.yellow { color: yellow; }
389
390span.aqua-background { background: aqua; }
391span.black-background { background: black; }
392span.blue-background { background: blue; }
393span.fuchsia-background { background: fuchsia; }
394span.gray-background { background: gray; }
395span.green-background { background: green; }
396span.lime-background { background: lime; }
397span.maroon-background { background: maroon; }
398span.navy-background { background: navy; }
399span.olive-background { background: olive; }
400span.purple-background { background: purple; }
401span.red-background { background: red; }
402span.silver-background { background: silver; }
403span.teal-background { background: teal; }
404span.white-background { background: white; }
405span.yellow-background { background: yellow; }
406
407span.big { font-size: 2em; }
408span.small { font-size: 0.6em; }
409
410span.underline { text-decoration: underline; }
411span.overline { text-decoration: overline; }
412span.line-through { text-decoration: line-through; }
413
414div.unbreakable { page-break-inside: avoid; }
415
416
417/*
418 * xhtml11 specific
419 *
420 * */
421
422div.tableblock {
423 margin-top: 1.0em;
424 margin-bottom: 1.5em;
Junio C Hamanof2b74942012-11-20 21:06:26425}
Junio C Hamano9d971152012-12-19 00:43:11426div.tableblock > table {
427 border: 3px solid #527bbd;
428}
429thead, p.table.header {
Junio C Hamanof2b74942012-11-20 21:06:26430 font-weight: bold;
Junio C Hamano9d971152012-12-19 00:43:11431 color: #527bbd;
432}
433p.table {
434 margin-top: 0;
435}
436/* Because the table frame attribute is overriden by CSS in most browsers. */
437div.tableblock > table[frame="void"] {
438 border-style: none;
439}
440div.tableblock > table[frame="hsides"] {
441 border-left-style: none;
442 border-right-style: none;
443}
444div.tableblock > table[frame="vsides"] {
445 border-top-style: none;
446 border-bottom-style: none;
Junio C Hamanof2b74942012-11-20 21:06:26447}
448
Junio C Hamano9d971152012-12-19 00:43:11449
450/*
451 * html5 specific
452 *
453 * */
454
455table.tableblock {
456 margin-top: 1.0em;
457 margin-bottom: 1.5em;
458}
459thead, p.tableblock.header {
460 font-weight: bold;
461 color: #527bbd;
462}
463p.tableblock {
464 margin-top: 0;
465}
466table.tableblock {
467 border-width: 3px;
468 border-spacing: 0px;
469 border-style: solid;
470 border-color: #527bbd;
471 border-collapse: collapse;
472}
473th.tableblock, td.tableblock {
474 border-width: 1px;
475 padding: 4px;
476 border-style: solid;
477 border-color: #527bbd;
Junio C Hamanof2b74942012-11-20 21:06:26478}
479
Junio C Hamano9d971152012-12-19 00:43:11480table.tableblock.frame-topbot {
481 border-left-style: hidden;
482 border-right-style: hidden;
483}
484table.tableblock.frame-sides {
485 border-top-style: hidden;
486 border-bottom-style: hidden;
487}
488table.tableblock.frame-none {
489 border-style: hidden;
490}
491
492th.tableblock.halign-left, td.tableblock.halign-left {
493 text-align: left;
494}
495th.tableblock.halign-center, td.tableblock.halign-center {
496 text-align: center;
497}
498th.tableblock.halign-right, td.tableblock.halign-right {
Junio C Hamanof2b74942012-11-20 21:06:26499 text-align: right;
500}
501
Junio C Hamano9d971152012-12-19 00:43:11502th.tableblock.valign-top, td.tableblock.valign-top {
503 vertical-align: top;
Junio C Hamanof2b74942012-11-20 21:06:26504}
Junio C Hamano9d971152012-12-19 00:43:11505th.tableblock.valign-middle, td.tableblock.valign-middle {
506 vertical-align: middle;
507}
508th.tableblock.valign-bottom, td.tableblock.valign-bottom {
509 vertical-align: bottom;
Junio C Hamanof2b74942012-11-20 21:06:26510}
511
Junio C Hamano9d971152012-12-19 00:43:11512
513/*
514 * manpage specific
515 *
516 * */
517
518body.manpage h1 {
519 padding-top: 0.5em;
520 padding-bottom: 0.5em;
521 border-top: 2px solid silver;
522 border-bottom: 2px solid silver;
523}
524body.manpage h2 {
525 border-style: none;
526}
527body.manpage div.sectionbody {
528 margin-left: 3em;
Junio C Hamanof2b74942012-11-20 21:06:26529}
530
Junio C Hamano9d971152012-12-19 00:43:11531@media print {
532 body.manpage div#toc { display: none; }
533}
534
535
Junio C Hamanof2b74942012-11-20 21:06:26536</style>
537<script type="text/javascript">
538/*<![CDATA[*/
Junio C Hamanof2b74942012-11-20 21:06:26539var asciidoc = { // Namespace.
540
541/////////////////////////////////////////////////////////////////////
542// Table Of Contents generator
543/////////////////////////////////////////////////////////////////////
544
545/* Author: Mihai Bazon, September 2002
546 * http://students.infoiasi.ro/~mishoo
547 *
548 * Table Of Content generator
549 * Version: 0.4
550 *
551 * Feel free to use this script under the terms of the GNU General Public
552 * License, as long as you do not remove or alter this notice.
553 */
554
555 /* modified by Troy D. Hanson, September 2006. License: GPL */
556 /* modified by Stuart Rackham, 2006, 2009. License: GPL */
557
558// toclevels = 1..4.
559toc: function (toclevels) {
560
561 function getText(el) {
562 var text = "";
563 for (var i = el.firstChild; i != null; i = i.nextSibling) {
564 if (i.nodeType == 3 /* Node.TEXT_NODE */) // IE doesn't speak constants.
565 text += i.data;
566 else if (i.firstChild != null)
567 text += getText(i);
568 }
569 return text;
570 }
571
572 function TocEntry(el, text, toclevel) {
573 this.element = el;
574 this.text = text;
575 this.toclevel = toclevel;
576 }
577
578 function tocEntries(el, toclevels) {
579 var result = new Array;
Junio C Hamano9d971152012-12-19 00:43:11580 var re = new RegExp('[hH]([1-'+(toclevels+1)+'])');
Junio C Hamanof2b74942012-11-20 21:06:26581 // Function that scans the DOM tree for header elements (the DOM2
582 // nodeIterator API would be a better technique but not supported by all
583 // browsers).
584 var iterate = function (el) {
585 for (var i = el.firstChild; i != null; i = i.nextSibling) {
586 if (i.nodeType == 1 /* Node.ELEMENT_NODE */) {
587 var mo = re.exec(i.tagName);
588 if (mo && (i.getAttribute("class") || i.getAttribute("className")) != "float") {
589 result[result.length] = new TocEntry(i, getText(i), mo[1]-1);
590 }
591 iterate(i);
592 }
593 }
594 }
595 iterate(el);
596 return result;
597 }
598
599 var toc = document.getElementById("toc");
Junio C Hamano9d971152012-12-19 00:43:11600 if (!toc) {
601 return;
602 }
603
604 // Delete existing TOC entries in case we're reloading the TOC.
605 var tocEntriesToRemove = [];
606 var i;
607 for (i = 0; i < toc.childNodes.length; i++) {
608 var entry = toc.childNodes[i];
609 if (entry.nodeName.toLowerCase() == 'div'
610 && entry.getAttribute("class")
611 && entry.getAttribute("class").match(/^toclevel/))
612 tocEntriesToRemove.push(entry);
613 }
614 for (i = 0; i < tocEntriesToRemove.length; i++) {
615 toc.removeChild(tocEntriesToRemove[i]);
616 }
617
618 // Rebuild TOC entries.
Junio C Hamanof2b74942012-11-20 21:06:26619 var entries = tocEntries(document.getElementById("content"), toclevels);
620 for (var i = 0; i < entries.length; ++i) {
621 var entry = entries[i];
622 if (entry.element.id == "")
623 entry.element.id = "_toc_" + i;
624 var a = document.createElement("a");
625 a.href = "#" + entry.element.id;
626 a.appendChild(document.createTextNode(entry.text));
627 var div = document.createElement("div");
628 div.appendChild(a);
629 div.className = "toclevel" + entry.toclevel;
630 toc.appendChild(div);
631 }
632 if (entries.length == 0)
633 toc.parentNode.removeChild(toc);
634},
635
636
637/////////////////////////////////////////////////////////////////////
638// Footnotes generator
639/////////////////////////////////////////////////////////////////////
640
641/* Based on footnote generation code from:
642 * http://www.brandspankingnew.net/archive/2005/07/format_footnote.html
643 */
644
645footnotes: function () {
Junio C Hamano9d971152012-12-19 00:43:11646 // Delete existing footnote entries in case we're reloading the footnodes.
647 var i;
Junio C Hamanof2b74942012-11-20 21:06:26648 var noteholder = document.getElementById("footnotes");
Junio C Hamano9d971152012-12-19 00:43:11649 if (!noteholder) {
650 return;
651 }
652 var entriesToRemove = [];
653 for (i = 0; i < noteholder.childNodes.length; i++) {
654 var entry = noteholder.childNodes[i];
655 if (entry.nodeName.toLowerCase() == 'div' && entry.getAttribute("class") == "footnote")
656 entriesToRemove.push(entry);
657 }
658 for (i = 0; i < entriesToRemove.length; i++) {
659 noteholder.removeChild(entriesToRemove[i]);
660 }
661
662 // Rebuild footnote entries.
663 var cont = document.getElementById("content");
Junio C Hamanof2b74942012-11-20 21:06:26664 var spans = cont.getElementsByTagName("span");
665 var refs = {};
666 var n = 0;
667 for (i=0; i<spans.length; i++) {
668 if (spans[i].className == "footnote") {
669 n++;
Junio C Hamano9d971152012-12-19 00:43:11670 var note = spans[i].getAttribute("data-note");
671 if (!note) {
672 // Use [\s\S] in place of . so multi-line matches work.
673 // Because JavaScript has no s (dotall) regex flag.
674 note = spans[i].innerHTML.match(/\s*\[([\s\S]*)]\s*/)[1];
675 spans[i].innerHTML =
676 "[<a id='_footnoteref_" + n + "' href='#_footnote_" + n +
677 "' title='View footnote' class='footnote'>" + n + "</a>]";
678 spans[i].setAttribute("data-note", note);
679 }
Junio C Hamanof2b74942012-11-20 21:06:26680 noteholder.innerHTML +=
681 "<div class='footnote' id='_footnote_" + n + "'>" +
682 "<a href='#_footnoteref_" + n + "' title='Return to text'>" +
683 n + "</a>. " + note + "</div>";
Junio C Hamanof2b74942012-11-20 21:06:26684 var id =spans[i].getAttribute("id");
685 if (id != null) refs["#"+id] = n;
686 }
687 }
688 if (n == 0)
689 noteholder.parentNode.removeChild(noteholder);
690 else {
691 // Process footnoterefs.
692 for (i=0; i<spans.length; i++) {
693 if (spans[i].className == "footnoteref") {
694 var href = spans[i].getElementsByTagName("a")[0].getAttribute("href");
695 href = href.match(/#.*/)[0]; // Because IE return full URL.
696 n = refs[href];
697 spans[i].innerHTML =
698 "[<a href='#_footnote_" + n +
699 "' title='View footnote' class='footnote'>" + n + "</a>]";
700 }
701 }
702 }
Junio C Hamano9d971152012-12-19 00:43:11703},
704
705install: function(toclevels) {
706 var timerId;
707
708 function reinstall() {
709 asciidoc.footnotes();
710 if (toclevels) {
711 asciidoc.toc(toclevels);
712 }
713 }
714
715 function reinstallAndRemoveTimer() {
716 clearInterval(timerId);
717 reinstall();
718 }
719
720 timerId = setInterval(reinstall, 500);
721 if (document.addEventListener)
722 document.addEventListener("DOMContentLoaded", reinstallAndRemoveTimer, false);
723 else
724 window.onload = reinstallAndRemoveTimer;
Junio C Hamanof2b74942012-11-20 21:06:26725}
726
727}
Junio C Hamano9d971152012-12-19 00:43:11728asciidoc.install();
Junio C Hamanof2b74942012-11-20 21:06:26729/*]]>*/
730</script>
731</head>
Junio C Hamano9d971152012-12-19 00:43:11732<body class="article">
Junio C Hamanof2b74942012-11-20 21:06:26733<div id="header">
734<h1>Packfile transfer protocols</h1>
735</div>
736<div id="content">
737<div id="preamble">
738<div class="sectionbody">
739<div class="paragraph"><p>Git supports transferring data in packfiles over the ssh://, git:// and
740file:// transports. There exist two sets of protocols, one for pushing
741data from a client to a server and another for fetching data from a
742server to a client. All three transports (ssh, git, file) use the same
743protocol to transfer data.</p></div>
744<div class="paragraph"><p>The processes invoked in the canonical Git implementation are <em>upload-pack</em>
745on the server side and <em>fetch-pack</em> on the client side for fetching data;
746then <em>receive-pack</em> on the server and <em>send-pack</em> on the client for pushing
747data. The protocol functions to have a server tell a client what is
748currently on the server, then for the two to negotiate the smallest amount
749of data to send in order to fully update one or the other.</p></div>
750</div>
751</div>
Junio C Hamano9d971152012-12-19 00:43:11752<div class="sect1">
Junio C Hamanof2b74942012-11-20 21:06:26753<h2 id="_transports">Transports</h2>
754<div class="sectionbody">
755<div class="paragraph"><p>There are three transports over which the packfile protocol is
756initiated. The Git transport is a simple, unauthenticated server that
757takes the command (almost always <em>upload-pack</em>, though Git
758servers can be configured to be globally writable, in which <em>receive-
759pack</em> initiation is also allowed) with which the client wishes to
760communicate and executes it and connects it to the requesting
761process.</p></div>
762<div class="paragraph"><p>In the SSH transport, the client just runs the <em>upload-pack</em>
763or <em>receive-pack</em> process on the server over the SSH protocol and then
764communicates with that invoked process over the SSH connection.</p></div>
765<div class="paragraph"><p>The file:// transport runs the <em>upload-pack</em> or <em>receive-pack</em>
766process locally and communicates with it over a pipe.</p></div>
767</div>
Junio C Hamano9d971152012-12-19 00:43:11768</div>
769<div class="sect1">
Junio C Hamanof2b74942012-11-20 21:06:26770<h2 id="_git_transport">Git Transport</h2>
771<div class="sectionbody">
772<div class="paragraph"><p>The Git transport starts off by sending the command and repository
773on the wire using the pkt-line format, followed by a NUL byte and a
774hostname parameter, terminated by a NUL byte.</p></div>
775<div class="literalblock">
776<div class="content">
Junio C Hamano9d971152012-12-19 00:43:11777<pre><code>0032git-upload-pack /project.git\0host=myserver.com\0</code></pre>
Junio C Hamanof2b74942012-11-20 21:06:26778</div></div>
Junio C Hamano9d971152012-12-19 00:43:11779<div class="openblock">
780<div class="content">
Junio C Hamanof2b74942012-11-20 21:06:26781<div class="literalblock">
782<div class="content">
Junio C Hamano9d971152012-12-19 00:43:11783<pre><code>git-proto-request = request-command SP pathname NUL [ host-parameter NUL ]
Junio C Hamanof2b74942012-11-20 21:06:26784request-command = "git-upload-pack" / "git-receive-pack" /
785 "git-upload-archive" ; case sensitive
786pathname = *( %x01-ff ) ; exclude NUL
Junio C Hamano9d971152012-12-19 00:43:11787host-parameter = "host=" hostname [ ":" port ]</code></pre>
788</div></div>
Junio C Hamanof2b74942012-11-20 21:06:26789</div></div>
790<div class="paragraph"><p>Only host-parameter is allowed in the git-proto-request. Clients
791MUST NOT attempt to send additional parameters. It is used for the
792git-daemon name based virtual hosting. See --interpolated-path
793option to git daemon, with the %H/%CH format characters.</p></div>
794<div class="paragraph"><p>Basically what the Git client is doing to connect to an <em>upload-pack</em>
795process on the server side over the Git protocol is this:</p></div>
796<div class="literalblock">
797<div class="content">
Junio C Hamano9d971152012-12-19 00:43:11798<pre><code>$ echo -e -n \
Junio C Hamanof2b74942012-11-20 21:06:26799 "0039git-upload-pack /schacon/gitbook.git\0host=example.com\0" |
Junio C Hamano9d971152012-12-19 00:43:11800 nc -v example.com 9418</code></pre>
Junio C Hamanof2b74942012-11-20 21:06:26801</div></div>
802<div class="paragraph"><p>If the server refuses the request for some reasons, it could abort
803gracefully with an error message.</p></div>
804<div class="listingblock">
805<div class="content">
Junio C Hamano9d971152012-12-19 00:43:11806<pre><code> error-line = PKT-LINE("ERR" SP explanation-text)</code></pre>
Junio C Hamanof2b74942012-11-20 21:06:26807</div></div>
808</div>
Junio C Hamano9d971152012-12-19 00:43:11809</div>
810<div class="sect1">
Junio C Hamanof2b74942012-11-20 21:06:26811<h2 id="_ssh_transport">SSH Transport</h2>
812<div class="sectionbody">
813<div class="paragraph"><p>Initiating the upload-pack or receive-pack processes over SSH is
814executing the binary on the server via SSH remote execution.
815It is basically equivalent to running this:</p></div>
816<div class="literalblock">
817<div class="content">
Junio C Hamano9d971152012-12-19 00:43:11818<pre><code>$ ssh git.example.com "git-upload-pack '/project.git'"</code></pre>
Junio C Hamanof2b74942012-11-20 21:06:26819</div></div>
820<div class="paragraph"><p>For a server to support Git pushing and pulling for a given user over
821SSH, that user needs to be able to execute one or both of those
822commands via the SSH shell that they are provided on login. On some
823systems, that shell access is limited to only being able to run those
824two commands, or even just one of them.</p></div>
825<div class="paragraph"><p>In an ssh:// format URI, it&#8217;s absolute in the URI, so the <em>/</em> after
826the host name (or port number) is sent as an argument, which is then
827read by the remote git-upload-pack exactly as is, so it&#8217;s effectively
828an absolute path in the remote filesystem.</p></div>
829<div class="literalblock">
830<div class="content">
Junio C Hamano9d971152012-12-19 00:43:11831<pre><code> git clone ssh://user@example.com/project.git
Junio C Hamanof2b74942012-11-20 21:06:26832 |
833 v
Junio C Hamano9d971152012-12-19 00:43:11834ssh user@example.com "git-upload-pack '/project.git'"</code></pre>
Junio C Hamanof2b74942012-11-20 21:06:26835</div></div>
836<div class="paragraph"><p>In a "user@host:path" format URI, its relative to the user&#8217;s home
837directory, because the Git client will run:</p></div>
838<div class="literalblock">
839<div class="content">
Junio C Hamano9d971152012-12-19 00:43:11840<pre><code> git clone user@example.com:project.git
Junio C Hamanof2b74942012-11-20 21:06:26841 |
842 v
Junio C Hamano9d971152012-12-19 00:43:11843ssh user@example.com "git-upload-pack 'project.git'"</code></pre>
Junio C Hamanof2b74942012-11-20 21:06:26844</div></div>
845<div class="paragraph"><p>The exception is if a <em>~</em> is used, in which case
846we execute it without the leading <em>/</em>.</p></div>
847<div class="literalblock">
848<div class="content">
Junio C Hamano9d971152012-12-19 00:43:11849<pre><code> ssh://user@example.com/~alice/project.git,
Junio C Hamanof2b74942012-11-20 21:06:26850 |
851 v
Junio C Hamano9d971152012-12-19 00:43:11852ssh user@example.com "git-upload-pack '~alice/project.git'"</code></pre>
Junio C Hamanof2b74942012-11-20 21:06:26853</div></div>
854<div class="paragraph"><p>A few things to remember here:</p></div>
855<div class="ulist"><ul>
856<li>
857<p>
858The "command name" is spelled with dash (e.g. git-upload-pack), but
859 this can be overridden by the client;
860</p>
861</li>
862<li>
863<p>
864The repository path is always quoted with single quotes.
865</p>
866</li>
867</ul></div>
868</div>
Junio C Hamano9d971152012-12-19 00:43:11869</div>
870<div class="sect1">
Junio C Hamanof2b74942012-11-20 21:06:26871<h2 id="_fetching_data_from_a_server">Fetching Data From a Server</h2>
872<div class="sectionbody">
873<div class="paragraph"><p>When one Git repository wants to get data that a second repository
874has, the first can <em>fetch</em> from the second. This operation determines
875what data the server has that the client does not then streams that
876data down to the client in packfile format.</p></div>
877</div>
Junio C Hamano9d971152012-12-19 00:43:11878</div>
879<div class="sect1">
Junio C Hamanof2b74942012-11-20 21:06:26880<h2 id="_reference_discovery">Reference Discovery</h2>
881<div class="sectionbody">
882<div class="paragraph"><p>When the client initially connects the server will immediately respond
883with a listing of each reference it has (all branches and tags) along
884with the object name that each reference currently points to.</p></div>
885<div class="literalblock">
886<div class="content">
Junio C Hamano9d971152012-12-19 00:43:11887<pre><code>$ echo -e -n "0039git-upload-pack /schacon/gitbook.git\0host=example.com\0" |
Junio C Hamanof2b74942012-11-20 21:06:26888 nc -v example.com 9418
88900887217a7c7e582c46cec22a130adf4b9d7d950fba0 HEAD\0multi_ack thin-pack
890 side-band side-band-64k ofs-delta shallow no-progress include-tag
89100441d3fcd5ced445d1abc402225c0b8a1299641f497 refs/heads/integration
892003f7217a7c7e582c46cec22a130adf4b9d7d950fba0 refs/heads/master
893003cb88d2441cac0977faf98efc80305012112238d9d refs/tags/v0.9
894003c525128480b96c89e6418b1e40909bf6c5b2d580f refs/tags/v1.0
895003fe92df48743b7bc7d26bcaabfddde0a1e20cae47c refs/tags/v1.0^{}
Junio C Hamano9d971152012-12-19 00:43:118960000</code></pre>
Junio C Hamanof2b74942012-11-20 21:06:26897</div></div>
898<div class="paragraph"><p>Server SHOULD terminate each non-flush line using LF ("\n") terminator;
899client MUST NOT complain if there is no terminator.</p></div>
900<div class="paragraph"><p>The returned response is a pkt-line stream describing each ref and
901its current value. The stream MUST be sorted by name according to
902the C locale ordering.</p></div>
903<div class="paragraph"><p>If HEAD is a valid ref, HEAD MUST appear as the first advertised
904ref. If HEAD is not a valid ref, HEAD MUST NOT appear in the
905advertisement list at all, but other refs may still appear.</p></div>
906<div class="paragraph"><p>The stream MUST include capability declarations behind a NUL on the
907first ref. The peeled value of a ref (that is "ref^{}") MUST be
908immediately after the ref itself, if presented. A conforming server
909MUST peel the ref if it&#8217;s an annotated tag.</p></div>
910<div class="listingblock">
911<div class="content">
Junio C Hamano9d971152012-12-19 00:43:11912<pre><code> advertised-refs = (no-refs / list-of-refs)
Junio C Hamanof2b74942012-11-20 21:06:26913 flush-pkt
914
915 no-refs = PKT-LINE(zero-id SP "capabilities^{}"
916 NUL capability-list LF)
917
918 list-of-refs = first-ref *other-ref
919 first-ref = PKT-LINE(obj-id SP refname
920 NUL capability-list LF)
921
922 other-ref = PKT-LINE(other-tip / other-peeled)
923 other-tip = obj-id SP refname LF
924 other-peeled = obj-id SP refname "^{}" LF
925
926 capability-list = capability *(SP capability)
927 capability = 1*(LC_ALPHA / DIGIT / "-" / "_")
Junio C Hamano9d971152012-12-19 00:43:11928 LC_ALPHA = %x61-7A</code></pre>
Junio C Hamanof2b74942012-11-20 21:06:26929</div></div>
930<div class="paragraph"><p>Server and client MUST use lowercase for obj-id, both MUST treat obj-id
931as case-insensitive.</p></div>
932<div class="paragraph"><p>See protocol-capabilities.txt for a list of allowed server capabilities
933and descriptions.</p></div>
934</div>
Junio C Hamano9d971152012-12-19 00:43:11935</div>
936<div class="sect1">
Junio C Hamanof2b74942012-11-20 21:06:26937<h2 id="_packfile_negotiation">Packfile Negotiation</h2>
938<div class="sectionbody">
939<div class="paragraph"><p>After reference and capabilities discovery, the client can decide to
940terminate the connection by sending a flush-pkt, telling the server it can
941now gracefully terminate, and disconnect, when it does not need any pack
942data. This can happen with the ls-remote command, and also can happen when
943the client already is up-to-date.</p></div>
944<div class="paragraph"><p>Otherwise, it enters the negotiation phase, where the client and
945server determine what the minimal packfile necessary for transport is,
946by telling the server what objects it wants, its shallow objects
947(if any), and the maximum commit depth it wants (if any). The client
948will also send a list of the capabilities it wants to be in effect,
949out of what the server said it could do with the first <em>want</em> line.</p></div>
950<div class="listingblock">
951<div class="content">
Junio C Hamano9d971152012-12-19 00:43:11952<pre><code> upload-request = want-list
Junio C Hamanof2b74942012-11-20 21:06:26953 *shallow-line
954 *1depth-request
955 flush-pkt
956
957 want-list = first-want
958 *additional-want
959
960 shallow-line = PKT_LINE("shallow" SP obj-id)
961
962 depth-request = PKT_LINE("deepen" SP depth)
963
964 first-want = PKT-LINE("want" SP obj-id SP capability-list LF)
965 additional-want = PKT-LINE("want" SP obj-id LF)
966
Junio C Hamano9d971152012-12-19 00:43:11967 depth = 1*DIGIT</code></pre>
Junio C Hamanof2b74942012-11-20 21:06:26968</div></div>
969<div class="paragraph"><p>Clients MUST send all the obj-ids it wants from the reference
970discovery phase as <em>want</em> lines. Clients MUST send at least one
971<em>want</em> command in the request body. Clients MUST NOT mention an
972obj-id in a <em>want</em> command which did not appear in the response
973obtained through ref discovery.</p></div>
974<div class="paragraph"><p>The client MUST write all obj-ids which it only has shallow copies
975of (meaning that it does not have the parents of a commit) as
976<em>shallow</em> lines so that the server is aware of the limitations of
977the client&#8217;s history. Clients MUST NOT mention an obj-id which
978it does not know exists on the server.</p></div>
979<div class="paragraph"><p>The client now sends the maximum commit history depth it wants for
980this transaction, which is the number of commits it wants from the
981tip of the history, if any, as a <em>deepen</em> line. A depth of 0 is the
982same as not making a depth request. The client does not want to receive
983any commits beyond this depth, nor objects needed only to complete
984those commits. Commits whose parents are not received as a result are
985defined as shallow and marked as such in the server. This information
986is sent back to the client in the next step.</p></div>
987<div class="paragraph"><p>Once all the <em>want&#8217;s and 'shallow&#8217;s (and optional 'deepen</em>) are
988transferred, clients MUST send a flush-pkt, to tell the server side
989that it is done sending the list.</p></div>
990<div class="paragraph"><p>Otherwise, if the client sent a positive depth request, the server
991will determine which commits will and will not be shallow and
992send this information to the client. If the client did not request
993a positive depth, this step is skipped.</p></div>
994<div class="listingblock">
995<div class="content">
Junio C Hamano9d971152012-12-19 00:43:11996<pre><code> shallow-update = *shallow-line
Junio C Hamanof2b74942012-11-20 21:06:26997 *unshallow-line
998 flush-pkt
999
1000 shallow-line = PKT-LINE("shallow" SP obj-id)
1001
Junio C Hamano9d971152012-12-19 00:43:111002 unshallow-line = PKT-LINE("unshallow" SP obj-id)</code></pre>
Junio C Hamanof2b74942012-11-20 21:06:261003</div></div>
1004<div class="paragraph"><p>If the client has requested a positive depth, the server will compute
1005the set of commits which are no deeper than the desired depth. The set
1006of commits start at the client&#8217;s wants.</p></div>
1007<div class="paragraph"><p>The server writes <em>shallow</em> lines for each
1008commit whose parents will not be sent as a result. The server writes
1009an <em>unshallow</em> line for each commit which the client has indicated is
1010shallow, but is no longer shallow at the currently requested depth
1011(that is, its parents will now be sent). The server MUST NOT mark
1012as unshallow anything which the client has not indicated was shallow.</p></div>
1013<div class="paragraph"><p>Now the client will send a list of the obj-ids it has using <em>have</em>
1014lines, so the server can make a packfile that only contains the objects
1015that the client needs. In multi_ack mode, the canonical implementation
1016will send up to 32 of these at a time, then will send a flush-pkt. The
1017canonical implementation will skip ahead and send the next 32 immediately,
1018so that there is always a block of 32 "in-flight on the wire" at a time.</p></div>
1019<div class="listingblock">
1020<div class="content">
Junio C Hamano9d971152012-12-19 00:43:111021<pre><code> upload-haves = have-list
Junio C Hamanof2b74942012-11-20 21:06:261022 compute-end
1023
1024 have-list = *have-line
1025 have-line = PKT-LINE("have" SP obj-id LF)
Junio C Hamano9d971152012-12-19 00:43:111026 compute-end = flush-pkt / PKT-LINE("done")</code></pre>
Junio C Hamanof2b74942012-11-20 21:06:261027</div></div>
1028<div class="paragraph"><p>If the server reads <em>have</em> lines, it then will respond by ACKing any
1029of the obj-ids the client said it had that the server also has. The
1030server will ACK obj-ids differently depending on which ack mode is
1031chosen by the client.</p></div>
1032<div class="paragraph"><p>In multi_ack mode:</p></div>
1033<div class="ulist"><ul>
1034<li>
1035<p>
1036the server will respond with <em>ACK obj-id continue</em> for any common
1037 commits.
1038</p>
1039</li>
1040<li>
1041<p>
1042once the server has found an acceptable common base commit and is
1043 ready to make a packfile, it will blindly ACK all <em>have</em> obj-ids
1044 back to the client.
1045</p>
1046</li>
1047<li>
1048<p>
1049the server will then send a <em>NACK</em> and then wait for another response
1050 from the client - either a <em>done</em> or another list of <em>have</em> lines.
1051</p>
1052</li>
1053</ul></div>
1054<div class="paragraph"><p>In multi_ack_detailed mode:</p></div>
1055<div class="ulist"><ul>
1056<li>
1057<p>
1058the server will differentiate the ACKs where it is signaling
1059 that it is ready to send data with <em>ACK obj-id ready</em> lines, and
1060 signals the identified common commits with <em>ACK obj-id common</em> lines.
1061</p>
1062</li>
1063</ul></div>
1064<div class="paragraph"><p>Without either multi_ack or multi_ack_detailed:</p></div>
1065<div class="ulist"><ul>
1066<li>
1067<p>
1068upload-pack sends "ACK obj-id" on the first common object it finds.
1069 After that it says nothing until the client gives it a "done".
1070</p>
1071</li>
1072<li>
1073<p>
1074upload-pack sends "NAK" on a flush-pkt if no common object
1075 has been found yet. If one has been found, and thus an ACK
1076 was already sent, it&#8217;s silent on the flush-pkt.
1077</p>
1078</li>
1079</ul></div>
1080<div class="paragraph"><p>After the client has gotten enough ACK responses that it can determine
1081that the server has enough information to send an efficient packfile
1082(in the canonical implementation, this is determined when it has received
1083enough ACKs that it can color everything left in the --date-order queue
1084as common with the server, or the --date-order queue is empty), or the
1085client determines that it wants to give up (in the canonical implementation,
1086this is determined when the client sends 256 <em>have</em> lines without getting
1087any of them ACKed by the server - meaning there is nothing in common and
1088the server should just send all of its objects), then the client will send
1089a <em>done</em> command. The <em>done</em> command signals to the server that the client
1090is ready to receive its packfile data.</p></div>
1091<div class="paragraph"><p>However, the 256 limit <strong>only</strong> turns on in the canonical client
1092implementation if we have received at least one "ACK %s continue"
1093during a prior round. This helps to ensure that at least one common
1094ancestor is found before we give up entirely.</p></div>
1095<div class="paragraph"><p>Once the <em>done</em> line is read from the client, the server will either
1096send a final <em>ACK obj-id</em> or it will send a <em>NAK</em>. The server only sends
1097ACK after <em>done</em> if there is at least one common base and multi_ack or
1098multi_ack_detailed is enabled. The server always sends NAK after <em>done</em>
1099if there is no common base found.</p></div>
1100<div class="paragraph"><p>Then the server will start sending its packfile data.</p></div>
1101<div class="listingblock">
1102<div class="content">
Junio C Hamano9d971152012-12-19 00:43:111103<pre><code> server-response = *ack_multi ack / nak
Junio C Hamanof2b74942012-11-20 21:06:261104 ack_multi = PKT-LINE("ACK" SP obj-id ack_status LF)
1105 ack_status = "continue" / "common" / "ready"
1106 ack = PKT-LINE("ACK SP obj-id LF)
Junio C Hamano9d971152012-12-19 00:43:111107 nak = PKT-LINE("NAK" LF)</code></pre>
Junio C Hamanof2b74942012-11-20 21:06:261108</div></div>
1109<div class="paragraph"><p>A simple clone may look like this (with no <em>have</em> lines):</p></div>
1110<div class="listingblock">
1111<div class="content">
Junio C Hamano9d971152012-12-19 00:43:111112<pre><code> C: 0054want 74730d410fcb6603ace96f1dc55ea6196122532d multi_ack \
Junio C Hamanof2b74942012-11-20 21:06:261113 side-band-64k ofs-delta\n
1114 C: 0032want 7d1665144a3a975c05f1f43902ddaf084e784dbe\n
1115 C: 0032want 5a3f6be755bbb7deae50065988cbfa1ffa9ab68a\n
1116 C: 0032want 7e47fe2bd8d01d481f44d7af0531bd93d3b21c01\n
1117 C: 0032want 74730d410fcb6603ace96f1dc55ea6196122532d\n
1118 C: 0000
1119 C: 0009done\n
1120
1121 S: 0008NAK\n
Junio C Hamano9d971152012-12-19 00:43:111122 S: [PACKFILE]</code></pre>
Junio C Hamanof2b74942012-11-20 21:06:261123</div></div>
1124<div class="paragraph"><p>An incremental update (fetch) response might look like this:</p></div>
1125<div class="listingblock">
1126<div class="content">
Junio C Hamano9d971152012-12-19 00:43:111127<pre><code> C: 0054want 74730d410fcb6603ace96f1dc55ea6196122532d multi_ack \
Junio C Hamanof2b74942012-11-20 21:06:261128 side-band-64k ofs-delta\n
1129 C: 0032want 7d1665144a3a975c05f1f43902ddaf084e784dbe\n
1130 C: 0032want 5a3f6be755bbb7deae50065988cbfa1ffa9ab68a\n
1131 C: 0000
1132 C: 0032have 7e47fe2bd8d01d481f44d7af0531bd93d3b21c01\n
1133 C: [30 more have lines]
1134 C: 0032have 74730d410fcb6603ace96f1dc55ea6196122532d\n
1135 C: 0000
1136
1137 S: 003aACK 7e47fe2bd8d01d481f44d7af0531bd93d3b21c01 continue\n
1138 S: 003aACK 74730d410fcb6603ace96f1dc55ea6196122532d continue\n
1139 S: 0008NAK\n
1140
1141 C: 0009done\n
1142
1143 S: 0031ACK 74730d410fcb6603ace96f1dc55ea6196122532d\n
Junio C Hamano9d971152012-12-19 00:43:111144 S: [PACKFILE]</code></pre>
Junio C Hamanof2b74942012-11-20 21:06:261145</div></div>
1146</div>
Junio C Hamano9d971152012-12-19 00:43:111147</div>
1148<div class="sect1">
Junio C Hamanof2b74942012-11-20 21:06:261149<h2 id="_packfile_data">Packfile Data</h2>
1150<div class="sectionbody">
1151<div class="paragraph"><p>Now that the client and server have finished negotiation about what
1152the minimal amount of data that needs to be sent to the client is, the server
1153will construct and send the required data in packfile format.</p></div>
1154<div class="paragraph"><p>See pack-format.txt for what the packfile itself actually looks like.</p></div>
1155<div class="paragraph"><p>If <em>side-band</em> or <em>side-band-64k</em> capabilities have been specified by
1156the client, the server will send the packfile data multiplexed.</p></div>
1157<div class="paragraph"><p>Each packet starting with the packet-line length of the amount of data
1158that follows, followed by a single byte specifying the sideband the
1159following data is coming in on.</p></div>
1160<div class="paragraph"><p>In <em>side-band</em> mode, it will send up to 999 data bytes plus 1 control
1161code, for a total of up to 1000 bytes in a pkt-line. In <em>side-band-64k</em>
1162mode it will send up to 65519 data bytes plus 1 control code, for a
1163total of up to 65520 bytes in a pkt-line.</p></div>
1164<div class="paragraph"><p>The sideband byte will be a <em>1</em>, <em>2</em> or a <em>3</em>. Sideband <em>1</em> will contain
1165packfile data, sideband <em>2</em> will be used for progress information that the
1166client will generally print to stderr and sideband <em>3</em> is used for error
1167information.</p></div>
1168<div class="paragraph"><p>If no <em>side-band</em> capability was specified, the server will stream the
1169entire packfile without multiplexing.</p></div>
1170</div>
Junio C Hamano9d971152012-12-19 00:43:111171</div>
1172<div class="sect1">
Junio C Hamanof2b74942012-11-20 21:06:261173<h2 id="_pushing_data_to_a_server">Pushing Data To a Server</h2>
1174<div class="sectionbody">
1175<div class="paragraph"><p>Pushing data to a server will invoke the <em>receive-pack</em> process on the
1176server, which will allow the client to tell it which references it should
1177update and then send all the data the server will need for those new
1178references to be complete. Once all the data is received and validated,
1179the server will then update its references to what the client specified.</p></div>
1180</div>
Junio C Hamano9d971152012-12-19 00:43:111181</div>
1182<div class="sect1">
Junio C Hamanof2b74942012-11-20 21:06:261183<h2 id="_authentication">Authentication</h2>
1184<div class="sectionbody">
1185<div class="paragraph"><p>The protocol itself contains no authentication mechanisms. That is to be
1186handled by the transport, such as SSH, before the <em>receive-pack</em> process is
1187invoked. If <em>receive-pack</em> is configured over the Git transport, those
1188repositories will be writable by anyone who can access that port (9418) as
1189that transport is unauthenticated.</p></div>
1190</div>
Junio C Hamano9d971152012-12-19 00:43:111191</div>
1192<div class="sect1">
Junio C Hamanof2b74942012-11-20 21:06:261193<h2 id="_reference_discovery_2">Reference Discovery</h2>
1194<div class="sectionbody">
1195<div class="paragraph"><p>The reference discovery phase is done nearly the same way as it is in the
1196fetching protocol. Each reference obj-id and name on the server is sent
1197in packet-line format to the client, followed by a flush-pkt. The only
1198real difference is that the capability listing is different - the only
1199possible values are <em>report-status</em>, <em>delete-refs</em> and <em>ofs-delta</em>.</p></div>
1200</div>
Junio C Hamano9d971152012-12-19 00:43:111201</div>
1202<div class="sect1">
Junio C Hamanof2b74942012-11-20 21:06:261203<h2 id="_reference_update_request_and_packfile_transfer">Reference Update Request and Packfile Transfer</h2>
1204<div class="sectionbody">
1205<div class="paragraph"><p>Once the client knows what references the server is at, it can send a
1206list of reference update requests. For each reference on the server
1207that it wants to update, it sends a line listing the obj-id currently on
1208the server, the obj-id the client would like to update it to and the name
1209of the reference.</p></div>
1210<div class="paragraph"><p>This list is followed by a flush-pkt and then the packfile that should
1211contain all the objects that the server will need to complete the new
1212references.</p></div>
1213<div class="listingblock">
1214<div class="content">
Junio C Hamano9d971152012-12-19 00:43:111215<pre><code> update-request = command-list [pack-file]
Junio C Hamanof2b74942012-11-20 21:06:261216
1217 command-list = PKT-LINE(command NUL capability-list LF)
1218 *PKT-LINE(command LF)
1219 flush-pkt
1220
1221 command = create / delete / update
1222 create = zero-id SP new-id SP name
1223 delete = old-id SP zero-id SP name
1224 update = old-id SP new-id SP name
1225
1226 old-id = obj-id
1227 new-id = obj-id
1228
Junio C Hamano9d971152012-12-19 00:43:111229 pack-file = "PACK" 28*(OCTET)</code></pre>
Junio C Hamanof2b74942012-11-20 21:06:261230</div></div>
1231<div class="paragraph"><p>If the receiving end does not support delete-refs, the sending end MUST
1232NOT ask for delete command.</p></div>
1233<div class="paragraph"><p>The pack-file MUST NOT be sent if the only command used is <em>delete</em>.</p></div>
1234<div class="paragraph"><p>A pack-file MUST be sent if either create or update command is used,
1235even if the server already has all the necessary objects. In this
1236case the client MUST send an empty pack-file. The only time this
1237is likely to happen is if the client is creating
1238a new branch or a tag that points to an existing obj-id.</p></div>
1239<div class="paragraph"><p>The server will receive the packfile, unpack it, then validate each
1240reference that is being updated that it hasn&#8217;t changed while the request
1241was being processed (the obj-id is still the same as the old-id), and
1242it will run any update hooks to make sure that the update is acceptable.
1243If all of that is fine, the server will then update the references.</p></div>
1244</div>
Junio C Hamano9d971152012-12-19 00:43:111245</div>
1246<div class="sect1">
Junio C Hamanof2b74942012-11-20 21:06:261247<h2 id="_report_status">Report Status</h2>
1248<div class="sectionbody">
1249<div class="paragraph"><p>After receiving the pack data from the sender, the receiver sends a
1250report if <em>report-status</em> capability is in effect.
1251It is a short listing of what happened in that update. It will first
1252list the status of the packfile unpacking as either <em>unpack ok</em> or
1253<em>unpack [error]</em>. Then it will list the status for each of the references
1254that it tried to update. Each line is either <em>ok [refname]</em> if the
1255update was successful, or <em>ng [refname] [error]</em> if the update was not.</p></div>
1256<div class="listingblock">
1257<div class="content">
Junio C Hamano9d971152012-12-19 00:43:111258<pre><code> report-status = unpack-status
Junio C Hamanof2b74942012-11-20 21:06:261259 1*(command-status)
1260 flush-pkt
1261
1262 unpack-status = PKT-LINE("unpack" SP unpack-result LF)
1263 unpack-result = "ok" / error-msg
1264
1265 command-status = command-ok / command-fail
1266 command-ok = PKT-LINE("ok" SP refname LF)
1267 command-fail = PKT-LINE("ng" SP refname SP error-msg LF)
1268
Junio C Hamano9d971152012-12-19 00:43:111269 error-msg = 1*(OCTECT) ; where not "ok"</code></pre>
Junio C Hamanof2b74942012-11-20 21:06:261270</div></div>
1271<div class="paragraph"><p>Updates can be unsuccessful for a number of reasons. The reference can have
1272changed since the reference discovery phase was originally sent, meaning
1273someone pushed in the meantime. The reference being pushed could be a
1274non-fast-forward reference and the update hooks or configuration could be
1275set to not allow that, etc. Also, some references can be updated while others
1276can be rejected.</p></div>
1277<div class="paragraph"><p>An example client/server communication might look like this:</p></div>
1278<div class="listingblock">
1279<div class="content">
Junio C Hamano9d971152012-12-19 00:43:111280<pre><code> S: 007c74730d410fcb6603ace96f1dc55ea6196122532d refs/heads/local\0report-status delete-refs ofs-delta\n
Junio C Hamanof2b74942012-11-20 21:06:261281 S: 003e7d1665144a3a975c05f1f43902ddaf084e784dbe refs/heads/debug\n
1282 S: 003f74730d410fcb6603ace96f1dc55ea6196122532d refs/heads/master\n
1283 S: 003f74730d410fcb6603ace96f1dc55ea6196122532d refs/heads/team\n
1284 S: 0000
1285
1286 C: 003e7d1665144a3a975c05f1f43902ddaf084e784dbe 74730d410fcb6603ace96f1dc55ea6196122532d refs/heads/debug\n
1287 C: 003e74730d410fcb6603ace96f1dc55ea6196122532d 5a3f6be755bbb7deae50065988cbfa1ffa9ab68a refs/heads/master\n
1288 C: 0000
1289 C: [PACKDATA]
1290
1291 S: 000eunpack ok\n
1292 S: 0018ok refs/heads/debug\n
Junio C Hamano9d971152012-12-19 00:43:111293 S: 002ang refs/heads/master non-fast-forward\n</code></pre>
Junio C Hamanof2b74942012-11-20 21:06:261294</div></div>
1295</div>
1296</div>
Junio C Hamano9d971152012-12-19 00:43:111297</div>
Junio C Hamanof2b74942012-11-20 21:06:261298<div id="footnotes"><hr /></div>
1299<div id="footer">
1300<div id="footer-text">
Junio C Hamano9d971152012-12-19 00:43:111301Last updated 2012-11-20 13:06:02 PST
Junio C Hamanof2b74942012-11-20 21:06:261302</div>
1303</div>
1304</body>
1305</html>